<html><head>
  <meta charset="utf-8">
    <#assign base=request.contextPath  />
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>产康统计</title>
  <link rel="stylesheet" href="${base}/js/layui/css/layui.css" media="all">
  <style type="text/css">
form{
           padding: 20px;
             }
      .layui-btn-radius{
           border-radius: 5px;
          }
  </style>
</head>
	<body>
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
	  <legend>数据统计</legend>
	</fieldset>

	<div class="demoTable"style="padding:15px;">
            <button class="layui-btn layui-btn-radius" id="btn2" data-method="offset" type="button" style="background-color: #0092EF;">产康销售统计</button>
            <div class="layui-inline layui-form" style="float:right;" >
            <div class="layui-input-inline">

                <select name="modules" lay-verify="required" id="sech" lay-search="">
                    <option value="">请选择要搜索项目</option>

                </select>
            </div>

        	  <button class="layui-btn layui-btn-radius" id="btn1" data-type="reload" style="background-color: #0092EF;">搜索</button>
        </div>
      </div>

	<div id="main" style="height:600px;color: #0066CC;"></div>

<script src="${base}/js/layui/echarts.common.min.js"></script>
<script src="${base}/js/layui/layui.js " charset="utf-8"></script>
<script src="${base}/js/jquery.min.js"></script>
<script src="${base}/js/zhang.js"></script>
<script>
var bas="${base}"
var home_data=getDataByDicCode(bas,"home")
for(var i=0;i<home_data.length;i++){
$("#home").append(
'  <option value="'+home_data[i].id+'">'+home_data[i].name+'</option>'
)
}


var bas1="${base}"
var puding_data=findProject()
for(var i=0;i<puding_data.length;i++){
$("#sech").append(
    '<option value="'+puding_data[i].id+'">'+puding_data[i].project+'</option>'
)
}

var data1Arr=[];
var data2Arr=[];
layui.use(['form', 'layedit', 'laydate','layer','rate'], function(){
 var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,rate = layui.rate;
rate.render({
    elem: '#pingfen',
    theme: '#FE0000'
  })
   var active = {
      	offset: function(othis){
      	  var type = othis.data('type')
      	  ,text = othis.text();
  		  layer.open({
  		  type: 2,
  		  title: '信息',
  		  offset: 't',
  		  shadeClose:false ,
  		  area:['480px','300px'],
  		  content: '${base}/evaluate/producing_add',

  		});
  	}
    };
     $('#btn2').on('click', function(){
      var othis = $(this), method = othis.data('method');
      active[method] ? active[method].call(this, othis) : '';
    });

});
//星级评价
   function sub(){
   var star=0;
   $(".layui-rate").each(function(){
              $(this).find('li').find('i').each(function() {
               if($(this).attr("class")=='layui-icon layui-icon-rate-solid'){
                star+=1;
             }
         });
   });



var home =$("#home").val();
 var puding =$("#puding").val();
  $.ajax({
         type:"POST",
         url:"${base}/evaluate/addEvaluate",
         data:{"relationId":home,"star":star,"projectId":puding},
           success : function(data){
                $(".tk5").hide(200)
             initChar();
           }
     });


}
//清空
initChar(null);
function initChar(paramValue){
     data2Arr=[];
     data1Arr=[];

$.ajax({
        type : "POST", //提交方式
        url : "${base}/evaluate/countEvaStar",//路径
        data:{"param":paramValue},
        async:false,
        success : function(data) {//返回数据根据结果进行相应的处理
     for(var i=0;i<data.length;i++){
     data2Arr.push(data[i].star);
     data1Arr.push(data[i].project);
     }
       var myChart = echarts.init(document.getElementById('main'));
             // 指定图表的配置项和数据
             var option = {
                 title: {
                     text: '产康项目统计'
                 },
                 xAxis: {
               data: data1Arr
                               },
                 tooltip: {
                     trigger: 'axis',
                     axisPointer: {
                     type: 'cross',
                      label: {backgroundColor: '#283b56'
                       }
                      }
             },
                 yAxis: {},
                 series: [{
                     name: '销量',
                     type: 'bar',
                     barWidth: 35,//固定柱子宽度
                          data: data2Arr
                 }]
             };
        // 使用刚指定的配置项和数据显示图表。
             myChart.setOption(option);
			}

        });
}
function findProject(){
 var resultdata;
   $.ajax({
          type:"POST",
          url:"${base}/evaluate/findAllProject",
          async:false,
            success : function(data){
              resultdata=data;
            }
      });
      return resultdata;
 }

$('#btn1').on('click', function(){
    var whereData={};
    var sechLin=$("#sech").val();
    initChar(sechLin);



});

//键盘事件
     $("body").bind("keydown",function(e){
         // 兼容FF和IE和Opera
         var theEvent = e || window.event;
         var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
         if (code == 13) {
             //回车执行查询
             $("#btn1").click();
         }
     });

</script>
</body>
</html>